import os
from pathlib import Path

def create_jill_structure(base_path="."):
    """创建JIIL视频中心空目录结构（增强版）"""
    structure = {
        "JIIL_VideoHub": {
            "index.php": None,
            "short.php": None,
            "user.php": None,
            "api.php": None,
            "functions.php": None,
            "config.php": None,
            "assets": {
                "style.css": None,
                "scripts.js": None
            }
        },
        "storage": {
            "videos": None,
            "thumbnails": None,
            "metadata": None
        }
    }

    def safe_create(path, content):
        try:
            if content is None:
                if '.' in str(path):  # 文件
                    path.parent.mkdir(parents=True, exist_ok=True)
                    path.touch(exist_ok=True)
                    print(f"创建文件: {path}")
                else:  # 目录
                    path.mkdir(parents=True, exist_ok=True)
                    print(f"创建目录: {path}")
            elif isinstance(content, dict):
                for name, sub_content in content.items():
                    safe_create(path / name, sub_content)
        except Exception as e:
            print(f"创建 {path} 时出错: {str(e)}")

    print("正在创建JIIL视频中心结构...")
    base = Path(base_path)
    for name, content in structure.items():
        safe_create(base / name, content)
    print("✅ 结构创建完成")

if __name__ == "__main__":
    create_jill_structure()